//
//  TCM_BaseViewController.swift
//  TCM_TradingProject
//
//  Created by 吕春海 on 2018/8/13.
//  Copyright © 2018年 lvchunhai. All rights reserved.
//

import UIKit
import FDFullscreenPopGesture
import IQKeyboardManagerSwift

class TCM_BaseViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.automaticallyAdjustsScrollViewInsets = false
        view.backgroundColor = TCM_HexRGB(0xFFFFFF)
        
        configNavi()
        IQKeyboardManager.shared.enable = true
        // Do any additional setup after loading the view.
    }
    
    func configNavi(){
        navigationController?.navigationBar.setBackgroundImage(nil, for: UIBarMetrics.default)
        navigationController?.navigationBar.barTintColor = TCM_HexRGB(0x501C02)
        navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
        navigationController?.navigationBar.barStyle = .default;
        navigationController?.navigationBar.tintColor = UIColor.white
        navigationController?.navigationBar.shadowImage = UIImage()
        
        navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .plain, target: self, action: #selector(popViewController))
        //主要是以下两个图片设置
        
        navigationController?.navigationBar.backIndicatorImage = UIImage(named: "TCM_BackWrite")
        navigationController?.navigationBar.backIndicatorTransitionMaskImage = UIImage(named: "TCM_BackWrite")
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        configNavi()
        
    }
    
    func hideLeftBarItem(){
        navigationItem.leftBarButtonItem = UIBarButtonItem()
    }
    
    @objc func popViewController() {
        navigationController?.popViewController(animated: true)
    }
    
    func hiddenNavBar() {
        self.fd_prefersNavigationBarHidden = true
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        view.endEditing(true)
    }
    
    override var shouldAutorotate: Bool {
        return false
    }
    
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .portrait
    }
}
